Skip to content

Reapply changes to support rich integration tests for fastly compute#589

Open
dpetrick wants to merge 6 commits intofastly:mainfrom
StellateHQ:dpetrick/reapply-integration-test-changes
Open

Reapply changes to support rich integration tests for fastly compute#589
dpetrick wants to merge 6 commits intofastly:mainfrom
StellateHQ:dpetrick/reapply-integration-test-changes

Conversation

@dpetrick
Copy link
Copy Markdown

@dpetrick dpetrick commented Mar 1, 2026

This PR extends Viceroy's public API to support richer integration testing by introducing several new capabilities or extending existing ones:

  • In-memory backend handlers (InMemoryBackendHandler trait + Handler wrapper): Backends can now be configured with custom async handlers that intercept requests and return responses without making real HTTP calls, enabling fully in-process integration tests.
  • Similarly, there's now a dynamic backend registration interceptor (yes, incredible name... DynamicBackendRegistrationInterceptor trait): Allows test harnesses to hook into dynamic backend registration and modify or augment backends as they are registered at runtime (e.g., to attach in-memory handlers).
  • Add Display trait to Cache and related structs to allow pretty printing. This is useful for debugging potentially incorrect cache state that the application produces.
  • Extend Cache with purge_all convenience method.
  • GuestHandle + run_to_completion(): The handle_request and spawn_guest call chains now return a GuestHandle so callers can await full guest completion (including async logging, cache writes, etc.) after receiving the HTTP response.
  • Logging endpoint monitoring (EndpointsMonitor / EndpointListener): Provides a channel-based mechanism to register listeners on named logging endpoints, allowing tests to capture and assert on log output from the guest.
  • ExecuteCtx::fork(): Allows creating a lightweight fork of an execution context that shares the compiled WASM engine/module but has fresh per-test state (cache, request IDs, pending reuse), making it efficient to run many tests against the same compiled guest.
  • Re-exported dependencies: async_trait, http, and hyper are now re-exported from the crate root so downstream consumers don't need to depend on matching versions.

dpetrick added 2 commits March 1, 2026 20:15
… fresh ExecuteCtxBuilder reusing the already-compiled Wasm engine and instance_pre. Unlike fork() (which copies existing config), this starts with all-default configuration

(empty backends, dictionaries, etc.) so the caller can set everything up from scratch. It also spawns its own epoch increment thread.

src/lib.rs — Re-exports ObjectKey and ObjectStoreKey from the object_store module, making them part of the public API.

src/session.rs — Changes endpoint monitor lookup from blocking_read() to try_read() on the RwLock, avoiding potential deadlocks if the lock is already held. Falls through silently if the lock can't be acquired.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant